package com.cans.service.pms.impl;


import com.cans.dao.api.IBaseDao;
import com.cans.dao.pms.api.ISysUserDao;
import com.cans.model.pms.SysUser;
import com.cans.service.impl.BaseServiceImpl;
import com.cans.service.pms.api.ISysUserService;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author: shencan
 * Date: 2017/10/3
 * Description:
 */
@Service("sysUserService")
public class SysUserServiceImpl extends BaseServiceImpl<SysUser,String> implements ISysUserService {

    @Resource
    private ISysUserDao sysUserDao;

    @Override
    public IBaseDao<SysUser, String> getDaoImpl() {
        return sysUserDao;
    }

    @Override
    public SysUser findOne(SysUser t){
        //创建匹配器，即如何使用查询条件  构建对象
        ExampleMatcher matcher = ExampleMatcher.matching()
                //姓名采用“开始匹配”的方式查询
                .withMatcher("userName", ExampleMatcher.GenericPropertyMatchers.startsWith())
                //忽略属性：是否关注。因为是基本类型，需要忽略掉
                .withIgnorePaths("focus");

        Example<SysUser> ex = Example.of(t, matcher);

        return getDaoImpl().findOne(ex);
    }
}
